package org.activity.sudoku;

import org.activity.sudoku.R;

import android.app.Activity;
import android.os.Bundle;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.util.Log;

public class SudokuActivity extends Activity implements OnClickListener{
	/** Called when the activity is first created. */
    
    private static final String TAG = "Sudoku";
    private void startGame(int i)
    {
    	Log.d(TAG, "clicked on" + i);
    }
    private void openNewGameDialog()
    {
    	new AlertDialog.Builder(this)
    	.setTitle(R.string.new_game_label)
    	.setItems(R.array.difficulty, new DialogInterface.OnClickListener()
    	{
			@Override
			public void onClick(DialogInterface dialog, int i) 
			{
				startGame(i);
			}
		})
		.show();
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
    	switch (item.getItemId())
    	{
    	case R.id.settings:
    		startActivity(new Intent(this, SettingsActivity.class));
    		return true;
    	case R.id.new_game_button:
    		openNewGameDialog();
    		break;
    	default:
    		break;
    	}
    	return false;
    }
    public boolean onCreateOptionsMenu(Menu menu)
    {
    	super.onCreateOptionsMenu(menu);
    	MenuInflater inflater = getMenuInflater();
    	inflater.inflate(R.menu.menu, menu);
    	return true;
    }
    public void onClick(View v) {
    	switch (v.getId()) {
    	case R.id.about_button:
    		Intent i = new Intent(this, AboutActivity.class);
    		startActivity(i);
    		break;
    	default:
    		break;
    	}
    }
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        View continueButton = this.findViewById(R.id.continue_button);
        continueButton.setOnClickListener(this);
        View new_gameButton = this.findViewById(R.id.new_game_button);
        new_gameButton.setOnClickListener(this);
        View aboutButton = this.findViewById(R.id.about_button);
        aboutButton.setOnClickListener(this);
        View exitButton = this.findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
    }
}